package services.implementation;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import services.IGenericService;

/**
 * @author smile
 */

public class GenericServices implements IGenericService{
    
    @PersistenceContext(unitName = "snPU")
    private EntityManager em;
    
    @Override
    public boolean insert(Object object) {
        try{
            em.persist(object);
            return true;
        }catch(Exception ex){
            return false;
        }
    }

    @Override
    public boolean delete(Object object) {
        try{
            em.remove(em.merge(object));
            return true;
        } catch (Exception ex){
            return false;
        }
    }

    @Override
    public boolean update(Object object) {
        try{
            em.merge(object);
            return true;
        }catch (Exception ex){
            return false;
        }
    }

}